package com.fjec.activity.config;

import com.fjec.common.rabbitmq.BaseCallback;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AmqpConfig {
    @Bean("secKillAmqpTemplate")
    public RabbitTemplate secKillAmqpTemplate(ConnectionFactory connectionFactory) {
        RabbitTemplate template = new RabbitTemplate(connectionFactory);
        BaseCallback baseCallback = new BaseCallback("MQ_SECKILL");
        //成功回调
        template.setConfirmCallback(baseCallback);
        //失败回调
        template.setReturnCallback(baseCallback);
        return template;
    }
}
